﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using knfProceduraAggiornamento;
using knfUpdateDataLayer.Aggiornamento;


namespace ProceduraReportsConsole
{
    public class GestioneInputFile
    {
        string _fileInputPath = string.Empty;

        public GestioneInputFile(string Inputfile)
        {
            _fileInputPath = Inputfile;
        }

        public void AnalizzaFilediInput()
        {

            ProceduraImportExport localProcedura = new ProceduraImportExport();
            int IDProcedura = localProcedura.CreaMacroProcedura(_fileInputPath);

            try
            {
                localProcedura.AnalizzaFilediInput(_fileInputPath);

                //ProceduraTotali localTotali = new ProceduraTotali(_connectionString);
                //localTotali.AggiornaTotaliPerAnno(_outputFilePath, 2011);
                //localTotali.AggiornaTotaliPerAnno(_outputFilePath, 2012);
            
                //ProceduraReport localReport = new ProceduraReport(_connectionString);

                //try
                //{
                //    localReport.GeneraReport(_outputFilePath);
                //}
                //catch (Exception ex)
                //{
                //    Console.WriteLine(ex.Message);
                //}

                localProcedura.ChiudiMacroProcedura(IDProcedura);
                localProcedura = null;
                //localTotali = null;
                //localReport = null;
            }
            catch (Exception ex)
            {
                localProcedura.ChiudiMacroProcedura(IDProcedura);
                localProcedura = null;
                throw ex;
            }
        }

    }
}
